@include('admin.public.head')
<link href="{{ URL::asset('./admin/css/main.css') }}" rel="stylesheet">
<body class="gray-bg">
	<style>
	 td{text-align:center;}
	 .add{color: #3b639f;text-decoration: none;margin-right: 10px;}
	 </style>
     <section class="wrapper wrapper-content animated fadeInRight">
      <div class="page_title">
       <h2 class="fl">管理员列表</h2>
		  <a class="add fr" href="/add">添加管理员</a>
      </div>
      <table class="table ibox-content">
       <tr>
        <th>账号</th>
        <th>角色名称</th>
        <th>上次登陆时间</th>
		<th>上次登陆Ip</th>
		<th>姓名</th>
        <th>操作</th>
       </tr>
        @foreach ($list as $vo)
	       <tr>
			<td>{{$vo->account}}</td>
			<td>{{$vo->role_name}}</td>
			<td>@if(!@empty ($vo->last_time)){{date("Y-m-d H:i:s",$vo->last_time)}}@endif</td>
			<td>{{$vo->last_ip}}</td>
			<td>{{$vo->real_name}}</td>
	        <td>
			 	<a href="/edit/{{$vo->id}}" class="inner_btn">编辑</a>
				<a href="javascript:void(0)" onclick="ban(this)" url="/ban/{{$vo->id}}" class="inner_btn" @if ($vo->status == 0)value="0">恢复正常@else value="1">禁止登录 @endif</a>
	         	<a onclick="dete(this)" href="javascript:void(0)" url="/admin_del/{{$vo->id}}"  class="inner_btn" >删除</a>
	        </td>
	       </tr>
   	    @endforeach
      </table>
       {{ $list->links() }}
     </section>
     <script>
	    $(document).ready(function(){
			$(".admin_tab li a").click(function(){
				var liindex = $(".admin_tab li a").index(this);
				$(this).addClass("active").parent().siblings().find("a").removeClass("active");
				$(".admin_tab_cont").eq(liindex).fadeIn(150).siblings(".admin_tab_cont").hide();
			});
		});

	    function ban(obj){
	    	var url = $(obj).attr('url');
	    	$.ajax({
                url:url,    //请求的url地址
                dataType:"json",   //返回格式为json
                type:"POST",   //请求方式
                success:function(req){
                    //请求成功时处理
                    if(req.status == 0){
                        layer.msg(req.message);
                        return false;
                    }

                    layer.msg('操作成功！');
	                setTimeout(function(){
	                    window.location.href = "/admin_li";
	                },500);
                }
            });
	    }

	    function dete(obj){
	    	var index = layer.confirm('是否确认删除!', {
			  btn: ['确认','取消'] //按钮
			}, function(){
			  	var url = $(obj).attr('url');
				$.ajax({
	                url:url,    //请求的url地址
	                dataType:"json",   //返回格式为json
	                type:"POST",   //请求方式
	                success:function(req){
	                    //请求成功时处理
	                    if(req.status == 0){
	                        layer.msg(req.message);
	                        return false;
	                    }

	                    layer.msg('操作成功！');
		                setTimeout(function(){
		                    window.location.href = "/admin_li";
		                },500);
	                }
	            });

			}, function(){
			  	layer.closer(index);
			});
	    }

     </script>

</body>
</html>
